<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page language="java" import="java.util.*,data.UserInfo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User Information</title>
<style type="text/css">

    #Profile {
            position:absolute;
            width:188px;
            height:436px;
            z-index:1;
            left: 2px;
            top: 187px;
            font-size: small;
    }
    .Text{
            font-size:small;
            }
    #UserList {
            position:absolute;
            width:800px;
            height:387px;
            z-index:2;
            left: 192px;
            top: 191px;
            font-size: small;
            font-style: normal;
            line-height: normal;
    }
    #Header {
            position:absolute;
            width:99%;
            height:48px;
            z-index:3;
            top: 6px;
            left: 4px;
    }
    #HelloUser {
            position:relative;
            width:130px;
            height:22px;
            z-index:1;
            float: right;
            top: 2px;
    }
    #uslstLabel {
            position:absolute;
            width:430px;
            height:30px;
            z-index:4;
            left: 192px;
            top: 162px;
    }
    .style1 {
            font-size: medium;
            font-weight: bold;
            font-style: normal;
            line-height: normal;
    }
    #Body {
            position:absolute;
            width:751px;
            height:721px;
            z-index:1;
            left: -7px;
            top: -34px;
    }
    #rightPane {
            position:absolute;
            width:182px;
            height:656px;
            z-index:1;
            left: 570px;
            top: 32px;
    }
    .noneDisplay{
        display: none;
    }
    .font{
        font-size: small;
    }
	.small-font{
		font-size:x-small;
		padding-left:0px;
	}
#Layer1 {
	position:absolute;
	width:186px;
	height:228px;
	z-index:5;
	left: 153px;
	top: 406px;
}

    
    
    .widthed{ 
        width:100%; 
    }
    .tbwidth1{
        width:160px;
    }
    .tbwidth2{
        width:200px;
    }
    .font{
        font-weight:bold;
    }
    .red {color: #FF0000}
    .none{display: none;}
    .inline{display: inline;}

</style>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
@import url("css/tablestyle.css");
.style7 {font-size: 40px}
.style8 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: 16px;
	font-style: italic;
}
.style12 {font-size: 16; font-weight: bold; color: #000000; }
.style14 {font-size: 16; color: #000000; }
.style15 {color: #000000}
#Layer3 {
	position:absolute;
	width:390px;
	height:373px;
	z-index:4;
	left: 400px;
	top: 297px;
}
#Layer4 {
	position:absolute;
	width:200px;
	height:115px;
	z-index:4;
}
#Layer5 {
	position:absolute;
	width:343px;
	height:115px;
	z-index:5;
	left: 293px;
	top: 186px;
}
-->
</style>
<link href="css/tablestyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<script>
        $(document).ready(function(){
            $("#id").focusout(function () {
                //var username = document.userform.username.value;
                var ID = document.userform.ID.value;
                var iD = parseInt(ID);
                if(isNaN(iD)){
                    $("#errID").css('display','block');
                      //$("#fo").text("focusout fired: " + fo + "x");
                }else {
                    $("#errID").fadeOut(1000);
                } 
                
            });
            $("#usrname").focusout(function(){
                var username = document.userform.username.value;
                
                if(username == "USER" || username == "user"){
                    $("#errName").css('display','block');
                }else{
                    $("#errName").fadeOut(1000);
                }
            });
            $("#quo").focusout(function(){
               var qcheckbox = document.getElementById("qcheck");
               if(qcheckbox.checked == false){
                   var Quota = document.userform.quota.value;
                   var quota = parseInt(Quota);
                   //alert(Quota + " " + quota);
                   if(isNaN(quota)){
                       //alert(quota);
                       $("#errQuota").css('display','block');
                   }else if(Quota < 0){
                       $("#errQuota").text("Quota cannot be negative!!")
                       $("#errQuota").css('display','block');
                   }else{
                       $("#errQuota").fadeOut(1000);
                   }
               }
            });
            $("#qcheck").change(
            function () 
            {   
                
                var qcheckbox = document.getElementById("qcheck");
                var quota = document.getElementById("quo");
                if(qcheckbox.checked == true){
                    quota.value = "UNLIMITED";
                    $('#quo').attr("readonly", true); 
                    $('#errQuota').fadeOut(1000);
                }else{
                    $('#quo').removeAttr("readonly");
                }
                
            });
            $('input[name="Submit"]').click(function(event){
                //event.preventDefault();
                var isChecked = document.userform.checkbox.checked;
                var field = document.getElementById("hide");
                if(isChecked == true){
                    field.value = "LOCK";
                }else{
                    field.value = "UNLOCK";
                }
                //$post("Add")
            });
        });
    </script>
<jsp:useBean id="user" class="data.UserInfo" scope="session"/>
<div id="header">
    	<div class="mainLogo">
            <div class="logo style7">Information System Security </div>
            <div class="author">
              <p class="style8">&nbsp;</p>
              <p class="style8">AUTHOR : GROUP 1</p>
            </div>
        </div>
        <div class="icons">
        	<a href=""></a>&nbsp;<a href=""></a>        </div>
        <div id="navcontainer">
            <ul id="navlist">
                <li id="active"><a href="UserInfo.jsp">HOME</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Profile.jsp">PROFILE </a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Role.jsp">ROLE</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Table.jsp">TABLE</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Contact.html">CONTACT</a></li>
            </ul>
        </div>
 <!-- TO DO -->   
<div id="Header">
  <div id="HelloUser">
      <div align="right">
          Hello <jsp:getProperty name="user" property="username"/>!
          <br>
          <a href="index.jsp">Sign out</a>      </div>
  </div>
</div>
</div>      
<div id="Profile">

<table border="1" width ="100%">
	<tr>
		<td>ID</td>
                <td><jsp:getProperty name="user" property="ID"/></td>
	</tr>
	<tr>
		<td>User Name</td>
		<td><jsp:getProperty name="user" property="username"/></td>
	</tr>
	
        <tr>
            <td>Default Tablespace</td>
            <%
                UserInfo userInf = (UserInfo)session.getAttribute("user");
                String deftbs = userInf.getDefTbspace();
                String tmptbs = userInf.getTmpTbspace();
                String accStt = userInf.getAccStatus();
                String quota = userInf.getQuota();
                String profile = userInf.getProfile();
            %>
            <td><%=deftbs%></td>
        </tr>
        <tr>
            <td>Temporary Tablespace</td>
            <td><%=tmptbs%></td>
        </tr>
        <tr>
            <td>Account status</td>
            <td><%=accStt%></td>
        </tr>
        <tr>
            <td>Quota</td>
            
            <td><%=quota%></td>
        </tr>
        <tr>
            <td>Profile</td>
            <td><%=profile%></td>
        </tr>
        
</table>
</div>
<form name="userform" method="post" action="Add">
<br><br><br>
</form>

<div id="Layer5">
  <table align="center" width="360px" class ="style">
    <tr>
      <td colspan=2 style="font-weight:bold;" align="center">Add User</td>
    </tr>
    <tr>
      <td colspan=2 align="center" height="10px"></td>
    </tr>
    <tr>
      <td class ="font tbwidth1">ID</td>
      <td class =" tbwidth2"><input id ="id" type="text" name="ID" value="" class="widthed">
          <div id ="errID" class="none red"> Wrong ID type (number only)</div></td>
    </tr>
    <tr>
      <td class ="font tbwidth1">UserName</td>
      <td class =" tbwidth2"><input id ="usrname" type="text" name="username" class ="widthed">
          <div id="errName" class="none red">This username is not acceptable!</div></td>
    </tr>
    <tr>
      <td class ="font tbwidth1">Password</td>
      <td class ="tbwidth2"><input type="password" name="password" class ="widthed"></td>
    </tr>
    <tr>
      <td class ="font tbwidth1">Default tablespace</td>
      <td class =" tbwidth2"><select id ="def" class="widthed" name ="defTbls">
          <%
                        ArrayList<String> defLst = (ArrayList<String>) session.getAttribute("defTbsList");
                        
                        for(int i = 0; i < defLst.size(); i++){
                            String name = defLst.get(i);
                        %>
          <option value="<%=name%>"><%=name%></option>
          <%
                        }
                        %>
        </select>
      </td>
    </tr>
    <tr>
      <td class ="font tbwidth1">Temporary tablespace</td>
      <td class =" tbwidth2"><select id ="tmp" class="widthed" name ="tmpTbls">
          <%
                        
                        ArrayList<String> tmpLst = (ArrayList<String>) session.getAttribute("tmpTbsList");
                        for(int i = 0; i < tmpLst.size(); i++){
                            String name = tmpLst.get(i);
                        %>
          <option value="<%=name%>"><%=name%></option>
          <%
                        }
                        %>
        </select>
      </td>
    </tr>
    <tr>
      <td class ="font tbwidth1">Quota</td>
      <td class =" tbwidth2"><input type="text" id="quo" name="quota" class ="widthed">
          <div id ="errQuota" class="none red"> Wrong quota type (number only)</div></td>
    </tr>
    <tr>
      <td></td>
      <td><input id ="qcheck" type="checkbox" name="qCheckbox">
          <div id ="unlimit" class ="inline" >Unlimited</div>
      </td>
    </tr>
    <tr>
      <td class ="font tbwidth1">Account status</td>
      <td class =" tbwidth2"><input  id ="hide" type="hidden" name ="status" class ="widthed">
          <input type="checkbox" name="checkbox">
      </td>
    </tr>
    <tr>
      <td class ="font tbwidth1">Profile</td>
      <td class =" tbwidth2"><select id ="pro" class="widthed" name ="profileList">
          <%
                        
                        ArrayList<String> profileList = (ArrayList<String>) session.getAttribute("profileList");
                        for(int i = 0; i < profileList.size(); i++){
                            String name = profileList.get(i);
                        %>
          <option value="<%=name%>"><%=name%></option>
          <%
                        }
                        %>
        </select>
      </td>
    </tr>
    <tr>
      <th colspan="2"><input type="submit" name="Submit" value="Save" style="background-color:#49743D;font-weight:bold;color:#ffffff;" align="center"></th>
    </tr>
    <tr>
      <th colspan=2 align="center" height="10px"></th>
    </tr>
  </table>
</div>
</body>
</html>